package date.calendar;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeTest {

    public static void main(String[] args) {
        Date d = new Date();
        String firstTime = new SimpleDateFormat("HH:mm:ss").format(d);
        System.out.println(firstTime);
        System.out.println(d.getTime());
        // 14:45:20 1477291520703
        // 14:48:36 1477291716840 196
        Long l1 = Long.valueOf("1477291520703");
        Long l2 = Long.valueOf("1477291716840");
        System.out.println((l2 - l1) / (1000 * 60));

        System.out.println(d.getTime() - 7 * 24 * 3600 * 1000);

        // 当前日期的前7天的日期
        String Tim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(d.getTime() - 7 * 24 * 3600 * 1000));
        System.out.println(Tim);

        System.out.println("========================");

        String fmtStr = "HH:mm";
        SimpleDateFormat sdf = new SimpleDateFormat(fmtStr);
        try {
            Date date1 = sdf.parse("08:00"); // 1970年
            Date date2 = sdf.parse("08:27");
            System.out.println((date2.getTime() - date1.getTime()) / 60000);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("========================");

        fmtStr = "yyyy-MM";
        sdf = new SimpleDateFormat(fmtStr);
        try {
            Date date3 = sdf.parse("2021-01");
            // 输入当月 1号
            System.out.println(date3);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("========================");

        int i = 10;
        i *= i - 3;
        System.out.println(i);
    }
}
